package com.kurumi.controller;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

public class TencentMapApiController {
	
	//添加字段   是否同步
	
	public static void main(String[] args) {
		
		 System.out.println("------------- 经纬度查询 -------------");
	        String Key = "MVNBZ-4QAC3-6RU3R-36RHT-CMBWZ-7KFVX";
	        StringBuffer sb = new StringBuffer("https://apis.map.qq.com/ws/geocoder/v1/?");
	        sb.append("address=山东省济南市漱玉平民大药房有限公司六里山南路二店");
	        sb.append("&key="+Key);
	        //"lng": 125.332428,            "lat": 43.905239
	        System.out.println("===>>> 查询链接："+sb.toString());
	        System.out.println(getURLContent(sb.toString()));

		
	}
	
	
	public static String getURLContent(String urlStr) {
        //请求的url
        URL url = null;
        //请求的输入流
        BufferedReader in = null;
        //输入流的缓冲
        StringBuffer sb = new StringBuffer();
        try{
            url = new URL(urlStr);
            in = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8") );
            String str = null;
            //一行一行进行读入
            while((str = in.readLine()) != null) {
                sb.append( str );
            }
        } catch (Exception ex) {
 
        } finally{
            try{
                if(in!=null) {
                    in.close(); //关闭流
                }
            }catch(IOException ex) {
 
            }
        }
        String result =sb.toString();
        return result;
    }
 
//    public static void main(String[] args) {
//        String s = getURLContent("https://apis.map.qq.com/ws/geocoder/v1/?address=北京市&key=1231313");
//        System.out.println(s);
//    }

}
